#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

void bubble (int a[], int n);
int swap (int *a, int *b);

int main()
{
 int a[100], i, n;
 //input the number of elements in array
 printf("\nHow many elements do you want to enter? -  ");   
 scanf("%d", &n);
 
 for(i=0; i<n; i++)
 {
          a[i]=rand()%100;
          printf("\n%d", a[i]);
          //scanf("%d", &a[i]);
          }
          bubble(a, n);
 //system("cls");
 printf("After sorted");
 for (i=0; i<n; i++)
     printf(" \n%d", a[i]);
          getch();
}

void bubble (int a[], int n)
{
     int i, j;
     
     for (i=n-1; i>0; i--)
         for (j=0; j<i; j++)
             if(a[j]>a[j+1]) swap(&a[j], &a[j+1]);
     }
     
int swap (int *a, int *b)
{
    int tmp;
    tmp=*a;
    *a=*b;
    *b=tmp;   
}
